<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <input type="text">
    <button class="set">存储</button>
    <button class="get">获得</button>
    <button class="remove">删除</button>
    <button class="del">清空</button>
    <script>
        var ipt = document.querySelector('input');
        var set = document.querySelector('.set');
        var get = document.querySelector('.get');
        var remove = document.querySelector('.remove')
        var del = document.querySelector('.del')
        set.addEventListener('click',function(){
            var val = ipt.value;
            sessionStorage.setItem('uname',val);
            sessionStorage.setItem('password',val);
        });
        get.addEventListener('click',function(){
            console.log(sessionStorage.getItem('uname'));
        })
        remove.addEventListener('click',function(){
           sessionStorage.removeItem('uname');
           sessionStorage.removeItem('password');
        })
        del.addEventListener('click',function(){
            sessionStorage.clear();
        })
    </script>
</body>
</html>